{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "04e0c605",
   "metadata": {},
   "source": [
    "# 慧眼辨喵"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "71e04e6e",
   "metadata": {},
   "source": [
    "## 1.  产品需求分析\n",
    "**产品描述**:一款帮助识别可爱的猫猫，为你挑选适合的猫猫品种。  \n",
    "**产品类型**:小程序。  \n",
    "**核心功能**:用户通过拍照or照片上传，经分析给出几个猫猫品种分析，给出百度百科链接和猫猫品种图片及详细描述。  \n",
    "\n",
    "## 2. 用户痛点\n",
    "* 看到一只猫，但不知道它的品种?  \n",
    "* 拍张照片，然后搜索!小程序会自动帮您分析。  \n",
    "* 混合品种?  \n",
    "* 没问题，我们会告诉你，它混合了哪些品种!  \n",
    "\n",
    "## 3. 用户画像\n",
    "**爱猫但不懂猫的人士**  \n",
    "**路上看到喜欢的猫猫想了解的人士**  \n",
    "**分析猫品种的人士**  \n",
    "![](小刘.png)\n",
    "\n",
    "## 4. 竞品分析\n",
    "> **AI识宠：** 支持面部比对和犬类鼻纹比对,知名度较高  \n",
    "> **慧眼辨喵：** 支持拍照上传品种猫猫，知名度较低\n",
    "![](111.png)\n",
    "![](222.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0c56ef59",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'refresh_token': '25.eee62cc6ac95bcd9d8c91633926818bf.315360000.1964958858.282335-25904770', 'expires_in': 2592000, 'session_key': '9mzdCrakVYIaT6Uv4mRFai4dAqeterycz7i7oQodXqCY4d9M5ytYfGM5wKKGVlf4jurpoe1Hu5oiQN4IUiWlpiuFFF79xg==', 'access_token': '24.120f6d0a824ab64188d787b689a98e42.2592000.1652190858.282335-25904770', 'scope': 'public vis-classify_dishes vis-classify_car brain_all_scope vis-classify_animal vis-classify_plant brain_object_detect brain_realtime_logo brain_dish_detect brain_car_detect brain_animal_classify brain_plant_classify brain_ingredient brain_advanced_general_classify brain_custom_dish brain_poi_recognize brain_vehicle_detect brain_redwine brain_currency brain_vehicle_damage brain_multi_ object_detect wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test权限 vis-classify_flower lpq_开放 cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base smartapp_mapp_dev_manage iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_开放Scope vis-ocr_虚拟人物助理 idl-video_虚拟人物助理 smartapp_component smartapp_search_plugin avatar_video_test b2b_tp_openapi b2b_tp_openapi_online', 'session_secret': 'b834ff08f40b65c5aed7e5173a639bb6'}\n"
     ]
    }
   ],
   "source": [
    "# encoding:utf-8\n",
    "import requests \n",
    "\n",
    "# client_id 为官网获取的AK， client_secret 为官网获取的SK\n",
    "host = 'https://aip.baidubce.com/oauth/2.0/token?'\n",
    "payload = {\n",
    "    'grant_type':'client_credentials',\n",
    "    'client_id':'xfEaT2GGjBc8ExifRtZlI2RT',\n",
    "    'client_secret':'7yVlFC2uCGvs0lRfmkVewvXNCoooLGy3'\n",
    "}\n",
    "response = requests.get(host,params=payload)\n",
    "if response:\n",
    "    print(response.json())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "815a89d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'24.120f6d0a824ab64188d787b689a98e42.2592000.1652190858.282335-25904770'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "access_token=response.json()['access_token']\n",
    "access_token"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1581d78a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': [{'name': '波斯猫',\n",
       "   'score': '0.334718',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E6%B3%A2%E6%96%AF%E7%8C%AB/585',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/cc11728b4710b9123e0206d7cefdfc03934522dc',\n",
       "    'description': '波斯猫(Persian cat)是以阿富汗的土种长毛猫和土耳其的安哥拉长毛猫为基础，在英国经过100多年的选种繁殖，于1860年诞生的一个品种。波斯猫是最常见的长毛猫，波斯猫有一张讨人喜爱的面庞，长而华丽的背毛，优雅的举止，故有“猫中王子”、“王妃”之称，是世界上爱猫者最喜欢的纯种猫之一，占有极其重要的地位。'}},\n",
       "  {'name': '狮子猫',\n",
       "   'score': '0.14565',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E7%8B%AE%E5%AD%90%E7%8C%AB/4340094',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/5882b2b7d0a20cf431ada5c49c415c36acaf2edd33dd',\n",
       "    'description': '狮子猫又称临清狮子猫，主要产于山东省临清市，是由蓝眼睛的波斯猫与黄眼睛的鲁西本地狸猫杂交繁育出来的变异品种。在诸多品种中，以一只蓝眼、一只黄眼，白毛拖地的雪狮子最为珍贵。人们称其为“鸳鸯眼狮猫”。临清狮子猫的培育形成与伊斯兰教的传人和运河的开通有密切的关系。到了明代，伴随着明朝与波斯的交往，波斯猫也在这里安家落户，加之波斯猫喜食羊的肝肾，便很快在回民家中繁衍开来。纯种临清狮子猫的颈、背部毛长达4—5厘米，站姿犹如狮子。也有黑白相间毛色的品种，但以纯白的较为珍贵。狮子猫身体强壮、抗病力强、耐寒冷、善于捕鼠。性格温婉，不喜欢陌生人，对主人有较强的依赖性。临清狮子猫因其独特的形象，一直是宠物市场上的高价极品猫。'}},\n",
       "  {'name': '家猫',\n",
       "   'score': '0.0908362',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E5%AE%B6%E7%8C%AB/4200676',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/f9dcd100baa1cd11e6db6e9db112c8fcc3ce2d19',\n",
       "    'description': '家猫(学名：Felis catus)俗称猫咪，是食肉目猫科、猫属哺乳动物。平均体重约有3～4.5公斤左右，大多数全身披毛，毛皮毛色纷繁，全身横纹者居多，少量为纯一色或杂色者。趾底有脂肪质肉垫，趾端生有锐利的爪，爪平时不伸出，故行走无声。家猫为人类伴生动物之一。它猎食小鸟、兔子、老鼠、鱼等。在世界各地(除南极洲)都被发现与人类一起生活。家猫在世界自然保护联盟红色名录,华盛顿公约没有特殊的地位。(概述图来源)'}},\n",
       "  {'name': '土耳其安哥拉猫', 'score': '0.063153', 'baike_info': {}},\n",
       "  {'name': '短毛猫',\n",
       "   'score': '0.0556292',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E7%9F%AD%E6%AF%9B%E7%8C%AB/6221174',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/d6ca7bcb0a46f21fce43b89ef7246b600d33ae8c',\n",
       "    'description': '短毛猫是家养猫，皮毛不长，很短。短毛猫可能有单层皮毛，也可能是双层皮毛。单层皮毛通常由一层纤细的丝绒般毛发形成，紧贴身体，比如暹罗猫,波曼猫；双层皮毛由外层粗长毛发和浓密柔软的绒毛内层组成，比如马恩岛猫,俄罗斯蓝猫。'}}],\n",
       " 'log_id': 1513153469883525449}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "动物识别\n",
    "'''\n",
    "\n",
    "request_url = \"https://aip.baidubce.com/rest/2.0/image-classify/v1/animal\"\n",
    "# 二进制方式打开图片文件\n",
    "f = open('cat1.jpeg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "payload = {\n",
    "    'access_token':access_token,\n",
    "    'image':img,\n",
    "    'top_num':5,\n",
    "    'baike_num':5,\n",
    "}\n",
    "\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data=payload, headers=headers)\n",
    "response.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "77b6f48e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': [{'name': '布偶猫',\n",
       "   'score': '0.362809',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E5%B8%83%E5%81%B6%E7%8C%AB/642121',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/4034970a304e251fc3ec88c8af86c9177f3e53e2',\n",
       "    'description': '布偶猫是猫中较大、较重的一种。它的头呈V形，眼大而圆，被毛丰厚，四肢粗大，尾长，身体柔软，多为三色或双色猫。布偶猫抱起来像软绵绵的布偶，而且对人非常友善。它性格大胆，不知道什么叫恐惧，而且对疼痛的忍耐性相当强，常被误认为缺乏疼痛感，因此很能容忍孩子的玩弄，是非常理想的家庭宠物。'}},\n",
       "  {'name': '喜马拉雅猫',\n",
       "   'score': '0.245088',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E5%96%9C%E9%A9%AC%E6%8B%89%E9%9B%85%E7%8C%AB/3488408',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/c83d70cf3bc79f3dcb655892bfa1cd11738b298f',\n",
       "    'description': '喜马拉雅猫，这个名字是由于它和叫这个名字的兔子的长相十分相似的缘故，而和喜马拉雅山无关。喜马拉雅猫融合了波斯猫的轻柔、妩媚和反应灵敏，暹罗猫的聪明和温雅。它有波斯猫的体态和长毛，暹罗猫的毛色和眼睛'}},\n",
       "  {'name': '伯曼猫',\n",
       "   'score': '0.149201',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E4%BC%AF%E6%9B%BC%E7%8C%AB/641852',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/359b033b5bb5c9ea1cc9764ddb39b6003af3b361',\n",
       "    'description': '伯曼猫又称缅甸圣猫，传说最早由古代缅甸寺庙里的僧侣饲养，视为护殿神猫，18世纪传入欧洲逐步进化定型。伯曼猫体型较长，身上被毛主要是浅金黄色，脸，耳，腿尾等部分毛色较深，呈咖啡色或深灰色，四爪为白色。颜色分为海豹色，蓝色，丁香色，巧克力色，红色，奶油色和玳瑁色，所有的颜色都可以附加山猫纹。据传，伯曼猫最早被缅甸圣僧所饲养。不过事实上，伯曼猫最早在法国被确定为固定品种，紧接着在英国也注册了这一品种。伯曼猫属于中型猫，有且仅有重点色块，肌肉结实，四肢中等长度，脚爪大而圆。头部宽圆适中，脸颊丰满，鼻子中等大小。眼睛差不多为圆形，眼角稍吊，为蓝宝石色。耳朵为暗色，中等大小，尖成圆弧形。尾巴中等长度。被毛长而细，且不易粘连。躯干毛色为浅色。胸部到腹部的毛呈波浪状。颇有特色的是伯曼猫的四肢末端为白色，被称为四肢踏雪，使它更加高贵。前肢的白色被称为手套，后肢的白色则被称为蕾丝，蕾丝的部位延伸得很长。伯曼猫温文尔雅，非常友善，叫声悦耳，喜欢与人作伴，对其他猫也十分友好。'}},\n",
       "  {'name': '家猫',\n",
       "   'score': '0.0442053',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E5%AE%B6%E7%8C%AB/4200676',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/f9dcd100baa1cd11e6db6e9db112c8fcc3ce2d19',\n",
       "    'description': '家猫(学名：Felis catus)俗称猫咪，是食肉目猫科、猫属哺乳动物。平均体重约有3～4.5公斤左右，大多数全身披毛，毛皮毛色纷繁，全身横纹者居多，少量为纯一色或杂色者。趾底有脂肪质肉垫，趾端生有锐利的爪，爪平时不伸出，故行走无声。家猫为人类伴生动物之一。它猎食小鸟、兔子、老鼠、鱼等。在世界各地(除南极洲)都被发现与人类一起生活。家猫在世界自然保护联盟红色名录,华盛顿公约没有特殊的地位。(概述图来源)'}},\n",
       "  {'name': '巴厘猫',\n",
       "   'score': '0.0426109',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E5%B7%B4%E5%8E%98%E7%8C%AB/641573',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/aa18972bd40735fa286c767899510fb30e240856',\n",
       "    'description': '巴厘猫是哈瓦那猫种群里的长毛型变种，是从在美国出生的暹逻猫幼崽中自然产生的毛发较长的个体演变过来的。巴厘猫背毛光滑漂亮，体态高雅，动物专家正是因为这种猫的优美体形和婀娜多姿的动作，联想起印尼巴厘岛土著舞蹈演员的姿态而给以命名的，实际上和巴厘岛没有地域关系。'}}],\n",
       " 'log_id': 1513153523138932004}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "动物识别\n",
    "'''\n",
    "\n",
    "request_url = \"https://aip.baidubce.com/rest/2.0/image-classify/v1/animal\"\n",
    "# 二进制方式打开图片文件\n",
    "f = open('cat2.jpeg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "payload = {\n",
    "    'access_token':access_token,\n",
    "    'image':img,\n",
    "    'top_num':5,\n",
    "    'baike_num':5,\n",
    "}\n",
    "\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data=payload, headers=headers)\n",
    "response.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "17b6ca22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': [{'name': '家猫',\n",
       "   'score': '0.441094',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E5%AE%B6%E7%8C%AB/4200676',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/f9dcd100baa1cd11e6db6e9db112c8fcc3ce2d19',\n",
       "    'description': '家猫(学名：Felis catus)俗称猫咪，是食肉目猫科、猫属哺乳动物。平均体重约有3～4.5公斤左右，大多数全身披毛，毛皮毛色纷繁，全身横纹者居多，少量为纯一色或杂色者。趾底有脂肪质肉垫，趾端生有锐利的爪，爪平时不伸出，故行走无声。家猫为人类伴生动物之一。它猎食小鸟、兔子、老鼠、鱼等。在世界各地(除南极洲)都被发现与人类一起生活。家猫在世界自然保护联盟红色名录,华盛顿公约没有特殊的地位。(概述图来源)'}},\n",
       "  {'name': '曼切堪猫',\n",
       "   'score': '0.161673',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E6%9B%BC%E5%88%87%E5%A0%AA%E7%8C%AB/901596',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/9f510fb30f2442a7e24b6bacdb43ad4bd1130275',\n",
       "    'description': '曼切堪猫身材中等，经常会迈着小短腿到处活动。十分可爱。为了彰显自己的萌态，它们也经常瞪着一双大眼睛，可怜巴巴地看着你。它们的毛主要有短毛和长毛两种．短毛的被毛长短适中，又厚又软，带有光泽，长毛触感丝滑，密度适中。'}},\n",
       "  {'name': '曼赤肯猫', 'score': '0.10657', 'baike_info': {}},\n",
       "  {'name': '索马里猫',\n",
       "   'score': '0.0531137',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E7%B4%A2%E9%A9%AC%E9%87%8C%E7%8C%AB/659651',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/6d81800a19d8bc3e6da0f458888ba61ea9d345fc',\n",
       "    'description': '索马里猫，(Somali )(索马利猫)大小中等，外表有王者风度。形似阿比西尼亚猫，但被毛为半长毛。体重：3.5到5.5公斤。活泼，但不热情过度。生命力顽强，温顺，性情温和，很贪玩，情感丰富，非常需要主人的关注，但较阿比西尼亚猫的占有欲弱。'}},\n",
       "  {'name': '狮子猫',\n",
       "   'score': '0.0276103',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E7%8B%AE%E5%AD%90%E7%8C%AB/4340094',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/5882b2b7d0a20cf431ada5c49c415c36acaf2edd33dd',\n",
       "    'description': '狮子猫又称临清狮子猫，主要产于山东省临清市，是由蓝眼睛的波斯猫与黄眼睛的鲁西本地狸猫杂交繁育出来的变异品种。在诸多品种中，以一只蓝眼、一只黄眼，白毛拖地的雪狮子最为珍贵。人们称其为“鸳鸯眼狮猫”。临清狮子猫的培育形成与伊斯兰教的传人和运河的开通有密切的关系。到了明代，伴随着明朝与波斯的交往，波斯猫也在这里安家落户，加之波斯猫喜食羊的肝肾，便很快在回民家中繁衍开来。纯种临清狮子猫的颈、背部毛长达4—5厘米，站姿犹如狮子。也有黑白相间毛色的品种，但以纯白的较为珍贵。狮子猫身体强壮、抗病力强、耐寒冷、善于捕鼠。性格温婉，不喜欢陌生人，对主人有较强的依赖性。临清狮子猫因其独特的形象，一直是宠物市场上的高价极品猫。'}}],\n",
       " 'log_id': 1513153570962737297}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "动物识别\n",
    "'''\n",
    "\n",
    "request_url = \"https://aip.baidubce.com/rest/2.0/image-classify/v1/animal\"\n",
    "# 二进制方式打开图片文件\n",
    "f = open('cat3.jpeg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "payload = {\n",
    "    'access_token':access_token,\n",
    "    'image':img,\n",
    "    'top_num':5,\n",
    "    'baike_num':5,\n",
    "}\n",
    "\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data=payload, headers=headers)\n",
    "response.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ed6b9f4c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': [{'name': '狮子猫',\n",
       "   'score': '0.229166',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E7%8B%AE%E5%AD%90%E7%8C%AB/4340094',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/5882b2b7d0a20cf431ada5c49c415c36acaf2edd33dd',\n",
       "    'description': '狮子猫又称临清狮子猫，主要产于山东省临清市，是由蓝眼睛的波斯猫与黄眼睛的鲁西本地狸猫杂交繁育出来的变异品种。在诸多品种中，以一只蓝眼、一只黄眼，白毛拖地的雪狮子最为珍贵。人们称其为“鸳鸯眼狮猫”。临清狮子猫的培育形成与伊斯兰教的传人和运河的开通有密切的关系。到了明代，伴随着明朝与波斯的交往，波斯猫也在这里安家落户，加之波斯猫喜食羊的肝肾，便很快在回民家中繁衍开来。纯种临清狮子猫的颈、背部毛长达4—5厘米，站姿犹如狮子。也有黑白相间毛色的品种，但以纯白的较为珍贵。狮子猫身体强壮、抗病力强、耐寒冷、善于捕鼠。性格温婉，不喜欢陌生人，对主人有较强的依赖性。临清狮子猫因其独特的形象，一直是宠物市场上的高价极品猫。'}},\n",
       "  {'name': '波斯猫',\n",
       "   'score': '0.227751',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E6%B3%A2%E6%96%AF%E7%8C%AB/585',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/cc11728b4710b9123e0206d7cefdfc03934522dc',\n",
       "    'description': '波斯猫(Persian cat)是以阿富汗的土种长毛猫和土耳其的安哥拉长毛猫为基础，在英国经过100多年的选种繁殖，于1860年诞生的一个品种。波斯猫是最常见的长毛猫，波斯猫有一张讨人喜爱的面庞，长而华丽的背毛，优雅的举止，故有“猫中王子”、“王妃”之称，是世界上爱猫者最喜欢的纯种猫之一，占有极其重要的地位。'}},\n",
       "  {'name': '金吉拉猫',\n",
       "   'score': '0.185936',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E9%87%91%E5%90%89%E6%8B%89%E7%8C%AB/659206',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/ac6eddc451da81cb7488327b5a66d0160924311d',\n",
       "    'description': '金吉拉猫，英文名为chinchilla，属于新品种的猫。金吉拉原产于英国，由波斯猫经过人为刻意培育而成。金吉拉四肢较短，体态比波斯猫稍娇小，但显得更灵巧。猫眼大而圆，眼珠的颜色以祖母绿、蓝绿或黄绿色为多。全身有浓密而光泽的毛，且毛量丰富。尾短而蓬松类似松鼠的尾巴，非常迷人。金吉拉猫身体强健矫捷，喜欢安静，性格温顺，自尊心也很强。'}},\n",
       "  {'name': '拿破仑猫', 'score': '0.132633', 'baike_info': {}},\n",
       "  {'name': '英国长毛猫',\n",
       "   'score': '0.0578435',\n",
       "   'baike_info': {'baike_url': 'http://baike.baidu.com/item/%E8%8B%B1%E5%9B%BD%E9%95%BF%E6%AF%9B%E7%8C%AB/6026734',\n",
       "    'image_url': 'https://bkimg.cdn.bcebos.com/pic/79f0f736afc37931761dce97ebc4b74543a91112',\n",
       "    'description': '英国长毛猫(BritishLonghair)聪明机警，独立性强；性情温顺。19世纪的末期，英国的育种专家们在这些土著猫中选出最美丽的猫咪，开始了漫长的培育工作，最终这个被称为英国长毛猫的品种诞生了。1871年，英国长毛猫参加了伦敦的水晶宫博览会，起品种也从此开始被命名。1901年，英国猫俱乐部成立了，那时的英国长毛猫还是体型大而结实的蓝色毛种，很像法国的卡尔特猫，后来由于它们的后代越来越像，甚至不分彼此。'}}],\n",
       " 'log_id': 1513153603442300031}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "动物识别\n",
    "'''\n",
    "\n",
    "request_url = \"https://aip.baidubce.com/rest/2.0/image-classify/v1/animal\"\n",
    "# 二进制方式打开图片文件\n",
    "f = open('cat4.jpeg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "payload = {\n",
    "    'access_token':access_token,\n",
    "    'image':img,\n",
    "    'top_num':5,\n",
    "    'baike_num':5,\n",
    "}\n",
    "\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data=payload, headers=headers)\n",
    "response.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e53a5bb1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
